<?php
//友情链接管理
namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Requests;

class UserController extends CommonController
{
    //后台会员管理
    public function index()
    {
		 $db = \DB::table("u_user");
		$data = $db->paginate(3);
		
		foreach($data as $v){
		if($v->power==1){
			$v->power="普通用户";
		}else{
			$v->power=$v->power."级管理";
		}
       }
        return view('admin.users.index',['list'=>$data]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
		
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function status($id)
    {
        
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {	
		$data = \DB::table("u_user")->where("id",$id)->first();
		$da = \DB::table("u_info")->where("uid",$id)->first();
        return view('admin.users.edit',['list'=>$data],['lists'=>$da]);
    }
    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
		$date = $request->only('status','power','member','grade');
		\DB::table("u_user")->where("id",$id)->update($date);
		 return redirect("admin/users/".$id."/edit");
    }
	
	

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
